<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <script>
    var book = {}
    var name = '' // 用来承接 book属性set后的替代值
    /*
    * 利用 Object.defineProperty 实现事件拦截
    * 本质是重写对象属性的 get set
     */
    Object.defineProperty(book, 'bName', {
      set(value) {
        name = value
      },
      get() {
        return `< ${name} >`
      }
    })
    book.bName = '告白' 
    // 其打印结果跟 vue实例中的 this.data 打印结果类似
    console.log(book) 
  </script>
</body>
</html>
